'use strict';
const {
	verifyToken
} = require("wx-common")

exports.main = async (event, context) => {
	const db = uniCloud.database()
	// 验证token
	const payload = event.token ? verifyToken(event.token) : null

	if (payload && payload.openid) {
		let res = db.collection('bookShelf').where({
			id: event.id
		}).remove()
		return {
			code: 200,
			message: "删除成功"
		}
	} else {
		return payload
	}
};
